﻿using Mod.Training.Models;
using Orchard;
using Orchard.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mod.Training.Service
{
    public interface ITrainingService : IDependency
    {
        void CreateItem(Item item);
        IEnumerable<Item> GetItems(int contentId);
    }

    public class TrainingService : ITrainingService
    {
        private readonly IRepository<Item> itemRepo;

        public TrainingService(IRepository<Item> itemRepo) 
        {
            this.itemRepo = itemRepo;
        }

        public void CreateItem(Item item) 
        {
            itemRepo.Create(item);
        }

        public IEnumerable<Item> GetItems(int contentId)
        {
            return itemRepo.Fetch(e => e.ItemListPartRecord.Id == contentId);
        }
    }
}
